
#pragma once

class CSglFrmWnd;

class CSglDoc : public CDocument
{

public:

	virtual ~CSglDoc();

	PSGLIMG GetImageInfo(UINT nSubIdx);

	PSGLINFO GetSglInfo(VOID);
	PSGLSUB GetCurrentSubFile(VOID);
	PSGLIMG GetCurrentImage(VOID);
	PSGLFRM GetCurrentFrame(VOID);
	PSGLSUB GetCurrentSubFile(UINT &nSubIdx);
	PSGLIMG GetCurrentImage(UINT &nImageIdx);
	PSGLFRM GetCurrentFrame(UINT &nImageIdx, UINT &nFrameIdx);

	PSGLSUB ChangeSubFile(UINT nSubIdx);
	PSGLFRM ChangeFrame(UINT nSubIdx, UINT nFrameIdx);

	VOID MoveToNextFrame(BOOL bLoop);
	VOID MoveToPrevFrame(BOOL bLoop);

	virtual BOOL OnNewDocument(VOID);
	virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
	virtual VOID OnCloseDocument(VOID);
	virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);

protected:

	typedef CMap<UINT, UINT, PSGLIMG, PSGLIMG>	CImageMap;

	UINT		m_SubIdx;
	UINT		m_ImageIdx;
	UINT		m_FrameIdx;
	PSGLINFO	m_SglInfo;
	HANDLE		m_CurFrame;
	CImageMap	m_ImageMap;

	CSglDoc();
	DECLARE_DYNCREATE(CSglDoc)

	CSglFrmWnd *GetMainFrame(VOID);
	VOID CleanUp(VOID);
	PSGLSUB UpdateSubFile(UINT nSubIdx);
	PSGLFRM UpdateFrame(UINT nSubIdx, UINT nFrameIdx);
	BOOL MoveToNextFrame(UINT &nImageIdx, UINT &nFrameIdx, BOOL bLoop);
	BOOL MoveToPrevFrame(UINT &nImageIdx, UINT &nFrameIdx, BOOL bLoop);

	INT MessageBox(LPCTSTR lpText, LPCTSTR lpCaption = NULL, UINT uType = MB_OK);

	DECLARE_MESSAGE_MAP()

};
